﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;
using System.Collections;
using Deployment.TeamFoundation.Entity;
using Deployment.TeamFoundation.Communication;

namespace Deployment.TeamFoundation.Logic
{
    public class SourceControl
    {
        #region [ Events ]
        public event EventHandler<TraceEventArgs> TraceEvent;
        #endregion [ Events ]

        #region [ Singleton ]

        private static SourceControl instance;

        public static SourceControl Instance
        {
            get
            {
                if (instance == null)
                {
                    Mutex mutex = new Mutex();
                    mutex.WaitOne();

                    if (instance == null)
                        instance = new SourceControl();

                    mutex.Close();
                }
                return instance;
            }
        }

        protected SourceControl()
        {
        }

        private void RaiseTraceEvent(string message)
        {
            if (TraceEvent != null)
                TraceEvent(this, new TraceEventArgs(message));
        }

        void Instance_TraceEvent(object sender, TraceEventArgs e)
        {
            throw new NotImplementedException();
        }

        void SourceControl_TraceEvent(object sender, TraceEventArgs e)
        {
            throw new NotImplementedException();
        }

        #endregion [ Singleton ]

        #region Public Methods

        public void CheckIn(CheckInRequest request)
        {
            //Communication.WorkspaceClient.Instance.CheckIn(request);
        }

        public void GetSource(string workspaceName, string sourcePath, string targetPath, bool destroyWorkspace, TFSGetType getType)
        {
            Communication.WorkspaceClient.Instance.GetSource(workspaceName, sourcePath, targetPath, destroyWorkspace, getType);
        }

        public void AddCheckinFileOrFolder(string workspaceName, string serverPath, string localPath)
        {
            Communication.WorkspaceClient.Instance.AddFileOrFolder(workspaceName, serverPath, localPath);
        }

        #endregion Public Methods
    }
}
